<template>
  <div class="app-container">
    <el-form :inline="true" :model="listQuery" @submit.native.prevent>
      <el-form-item label="搜索词">
        <el-input size="small" v-model="listQuery.q_keyword" minlength="2" maxlength="20"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="this.getList">查询</el-button>
        <el-button icon="el-icon-refresh-left" size="small" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      ref="singleTable"
      :data="dataList"
      v-loading="listLoading"
      border
      fit
      style="width: 100%">
      <el-table-column
        type="index"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        property="keyword"
        label="搜索词">
      </el-table-column>
      <el-table-column
        property="ip"
        label="IP地址">
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        property="siteCookie"
        label="cookie埋点">
      </el-table-column>
      <el-table-column
        property="memberId"
        label="用户ID">
      </el-table-column>
      <el-table-column
        width="160"
        property="createTime"
        label="创建时间">
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
  </div>
</template>
<script>
import { searchlogsListSearch } from '@/api/search'
import Pagination from '@/components/Pagination'
export default {
  name: 'logs',
  components: { Pagination },
  data() {
    return {
      dataList: [],
      total: 0,
      listLoading: false,
      listQuery: {
        q_keyword: '',
        page: 1,
        limit: 20
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      searchlogsListSearch(this.listQuery).then(res => {
        this.dataList = res.data.rows
        this.total = res.data.total
        this.listLoading = false
      })
    },
    reset() {
      this.listQuery.q_keyword = ''
      this.getList()
    }
  }
}
</script>
